{% extends './layout.html.twig' %}

{% block title %}Backtesting Results | Crypto Bot{% endblock %}

{% block stylesheet %}
    <link rel="stylesheet" href="/css/backtest.css?v={{ asset_version() }}">
{% endblock %}

{% block content %}
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <div class="container">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <h1>Backtesting Results <span class="text-muted"> - {{ strategy }} - {{ configuration.period }}</span></h1>
                    </div>
                    <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-right">
                            <li class="breadcrumb-item"><a href="{{ '/' }}">Dashboard</a></li>
                            <li class="breadcrumb-item active">Backtesting Results</li>
                        </ol>
                    </div>
                </div>
            </div><!-- /.container-fluid -->
        </section>
        <!-- /.Content Header (Page header) -->

        <!-- Main content -->
        <div class="content">
            <div class="container">
                <div class="row">
                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-header">
                                <h3 class="card-title">Summary <span class="text-muted"> - {{ start|date('y-m-d H:i:s') }} - {{ end|date('y-m-d H:i:s') }}</span></h3>
                            </div>
                            <!-- /.card-header -->
                            <div class="card-body">
                                {% include 'components/backtest_summary.html.twig' with {
                                    'summary': summary
                                } only %}
                            </div>
                            <!-- /.card-body -->
                        </div>
                        <!-- /.card -->
                        
                        <div class="card">
                            <div class="card-header">
                                <h3 class="card-title">Chart</h3>
                            </div>
                            <!-- /.card-header -->
                            <div class="card-body table-responsive p-0">
                                <div class="chart" data-candles="{{ candles|e('html') }}" data-title="{{ configuration.exchange }} - {{ configuration.symbol }} - {{ strategy }} - {{ configuration.period }} - espend.de"></div>
                            </div>
                            <!-- /.card-body -->
                        </div>
                        <!-- /.card -->

                        <div class="card">
                            <div class="card-header">
                                <h3 class="card-title">Signals</h3>
                            </div>
                            <!-- /.card-header -->
                            <div class="card-body table-responsive p-0">
                                {% if signals|length > 0 %}
                                    {% include 'components/backtest_table.html.twig' with {
                                        'rows': signals,
                                        'extra_fields': extra_fields,
                                    } only %}
                                {% else %}
                                    <p class="text-muted text-center">No signals given</p>
                                {% endif %}
                            </div>
                            <!-- /.card-body -->
                        </div>
                        <!-- /.card -->

                        <div class="card">
                            <div class="card-header">
                                <h3 class="card-title">Ticks</h3>
                            </div>
                            <!-- /.card-header -->
                            <div class="card-body table-responsive p-0">
                                {% include 'components/backtest_table.html.twig' with {
                                    'rows': rows,
                                    'extra_fields': extra_fields,
                                } only %}
                            </div>
                            <!-- /.card-body -->
                        </div>
                        <!-- /.card -->
                    </div>
                </div>
                <!-- /.row -->
            </div><!-- /.container-fluid -->
        </div>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
{% endblock %}

{% block javascript %}
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/techan.js/0.8.0/techan.min.js"></script>
<script src="/js/backtest.js?v={{ asset_version() }}"></script>
{% endblock %}
